home *** CD-ROM | disk | FTP | other *** search
- 1
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 63
- 64
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 81
- 81
- 81
- 82 static char input_buf[256],
- 83 b[256] = " ";
- 85
- 85 static char out_buf[256], dest[256], dummy[256];
- 86
- 87 static char *ibuf = input_buf, *bp = b, *obuf = out_buf, *tmp, *p;
- 88 static char *filebuf1 = 0 ,
- 89 *filebuf2 = 0 ;
- 90 static int line, len, mlen, dlen, count,
- 91 mode, newdata, hasdata, bquote, bquoteline, end,
- 92 verbose=1, secure=0, ambiguous, truncation=0,
- 93 t, i, x, y, z;
- 94 static int siz = 256;
- 95 static FILE *ofp;
- 96
- 97
- 98 int ExplodeFile();
- 99 int ExplodeLine();
- 100 int ExplodeLineCheck();
- 101
- 102
- 103
- 107
- 107
- 107
- 107 int uuchk(char *s)
- 108 {
- 109 int i, top;
- 110
- 111 top = len-(mlen-62);
- 112 for(i=1; i<top; i++)
- 113 if (*s++ >= 'a') return 0;
- 114 return 1;
- 115 }
- 116
- 117
- 118 main(int argc, char *argv[])
- 119 {
- 120 FILE *ifp;
- 121 char *pname;
- 122
- 123 pname = argv[0];
- 124 while (argc > 1 && *argv[1] == '-')
- 125 {
- 126 if (*(argv[1]+1) == 'q')
- 127 {
- 128 verbose = 0;
- 129 argc--;
- 130 argv++;
- 131 }
- 132 else if (*(argv[1]+1) == 'h')
- 133 {
- 134 printf("Usage: %s [-q | -h | -s] [file1 [file2...]]\n", argv[0]);
- 135 printf("-q quiet\n-h usage\n-s secure, check all data lines\n");
- 136 printf("When you get warnings check the input.\n");
- 137 return;
- 138 }
- 139 else if (*(argv[1]+1) == 's')
- 140 {
- 141 secure = 1;
- 142 argc--;
- 143 argv++;
- 144 }
- 145 }
- 146 ;
- 147 if (argc < 2)
- 148 {
- 149 line = 0;
- 150 ExplodeFile((&__iob[0]), "stdin");
- 151 }
- 152 else
- 153 {
- 154 if ((filebuf1 = malloc(262144)) == 0
- 155 || (filebuf2 = malloc(262144)) == 0 )
- 156 fprintf((&__iob[2]), "%s: buffer allocation failed.\n", pname);
- 157
- 158 for (; --argc && ++argv; )
- 159 {
- 160 if ((ifp = fopen(*argv,"r")) == 0 )
- 161 {
- 162 perror(*argv);
- 163 continue;
- 164 }
- 165 if (filebuf1 != 0 )
- 166 setvbuf(ifp, filebuf1,0x100 , 262144);
- 167 line = 0;
- 168 ExplodeFile(ifp, *argv);
- 169
- 170
- 171
- 172
- 173 fclose(ifp);
- 174 }
- 175 }
- 176 return;
- 177 }
- 178
- 179
- 180
- 181
- 182 int ExplodeFile(FILE *ifp, char *fname)
- 183 {
- 184 hasdata = mlen = 0;
- 185
- 186
- 187 while (fgets(ibuf, siz, ifp) != 0 )
- 188 {
- 189 while (1)
- 190 {
- 191 line++;
- 192 if (! strncmp(ibuf, "begin ", 6)
- 193 && (__ctype[ibuf[6]] & 32 )
- 194 && (__ctype[ibuf[7]] & 32 )
- 195 && (__ctype[ibuf[8]] & 32 ))
- 196 {
- 197 break;
- 198 }
- 199 if (fgets(ibuf, siz, ifp) == 0 )
- 200 {
- 201 if (! hasdata) printf("%s: no begin line\n", fname);
- 202 return;
- +++ Warning: non-value return in non-void function
- 203 }
- 204 }
- 205
- 206
- 207 if ((sscanf(ibuf, "begin %o%[ ]%s", &mode, dummy, dest)) != 3)
- 208 {
- 209 len = strlen(ibuf);
- 210 ibuf[len-1] = 0;
- 211 printf("%s: %s: Invalid mode or filename\n", fname, ibuf);
- 212 continue;
- 213 }
- 214 hasdata = 1;
- 215 if (verbose)
- 216 {
- 217 printf("Extracting <%s>\t", dest);
- 218
- 219 fflush((&__iob[1]));
- 220 }
- 221
- 222
- 223 if ((ofp = fopen(strcat(getenv("Out$path"),dest), "w")) == 0 )
- +++ Warning: <function argument>: implicit cast of non-0 int to pointer
- 224 {
- 225 perror(dest);
- 226 continue;
- 227 }
- 228
- 230
- 230 if (filebuf2 != 0 )
- 231 setvbuf(ofp, filebuf2,0x100 , 262144);
- 232
- 233
- 241
- 241
- 241
- 241
- 241
- 241
- 241
- 241 if (fgets(ibuf, siz, ifp) == 0 )
- 242 {
- 243 if (verbose) printf("\nEOF after begin\n");
- 244 fclose(ofp);
- 245
- 246 return;
- +++ Warning: non-value return in non-void function
- 247 }
- 248 line++;
- 249 len = strlen(ibuf);
- 250 if (*ibuf == 'M')
- 251 {
- 252 if ((mlen = len) < 62)
- 253 {
- 254 if (verbose) printf("\ninvalid first data line %d\n", line);
- 255 fclose(ofp);
- 256
- 257 continue;
- 258 }
- 259 if (! secure)
- 260 ExplodeLine(ibuf);
- 261 else if (! ExplodeLineCheck(ibuf))
- 262 {
- 263 if (verbose) printf("\nillegal chars in first data line %d\n", line);
- 264 fclose(ofp);
- 265
- 266 continue;
- 267 }
- 268 }
- 269 else if (*ibuf <= 'L' && *ibuf > ' ')
- 270 {
- 271 if (! secure)
- 272 ExplodeLine(ibuf);
- 273 else if (! ExplodeLineCheck(ibuf))
- 274 {
- 275 if (verbose) printf("\nillegal chars in short data line %d\n", line);
- 276 fclose(ofp);
- 277 continue;
- 278 }
- 279
- 280
- 281 if (fgets(ibuf, siz, ifp) == 0 )
- 282 {
- 283 if (verbose) printf("\nwarning: EOF after short data line\n");
- 284 fclose(ofp);
- 285 return;
- +++ Warning: non-value return in non-void function
- 286 }
- 287 len = strlen(ibuf);
- 288
- 289 if (len != 2 && len != 3 || *ibuf != ' ' && *ibuf != '`')
- 290 {
- 291 if (verbose) printf("\nwarning: garbage at end %d\n", line+1);
- 292
- 293 fseek(ifp, (long)-strlen(ibuf), 1);
- 294 fclose(ofp);
- 295 }
- 296 else
- 297 {
- 298 line++;
- 299 if (verbose) printf("-- done\n");
- 300 fclose(ofp);
- 301 }
- 302 continue;
- 303 }
- 304 else if ((*ibuf == ' ' || *ibuf == '`') && (len == 2 || len == 3))
- 305
- 306 {
- 307 if (verbose) printf("-- done\n");
- 308 fclose(ofp);
- 309 continue;
- 310 }
- 311 else
- 312 {
- 313 if (verbose) printf("\ngarbage at first line %d\n", line);
- 314 fclose(ofp);
- 315
- 316 continue;
- 317 }
- 318
- 319
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 402
- 403
- 404 *bp = ' ';
- 405
- 406 count = ambiguous = truncation = 0;
- 407 bquote = bquoteline = 0;
- 408 end = 0;
- 409 while (fgets(ibuf, siz, ifp) != 0 )
- 410 {
- 411 if ((newdata = ! strncmp(ibuf, "begin ", 6)
- 412 && (__ctype[ibuf[6]] & 32 )
- 413 && (__ctype[ibuf[7]] & 32 )
- 414 && (__ctype[ibuf[8]] & 32 )) )
- 416
- 416 {
- 417 fseek(ifp, (long)-strlen(ibuf), 1);
- 418 ExplodeLine(bp);
- 419 break;
- 420 }
- 421 line++;
- 422 len = strlen(ibuf);
- 423 if (*ibuf <= 'L' && *ibuf > ' ')
- 424 {
- 425 dlen = *ibuf-32;
- 426 t = dlen/3;
- 427 if (dlen%3) t++;
- 428 t = t << 2;
- 429 if (len == t+2+(mlen-62))
- 430 if (uuchk(ibuf))
- 431 {
- 432 tmp = bp;
- 433 bp = ibuf;
- 434 ibuf = tmp;
- 435 if (bquote)
- 436 {
- 437 if (verbose) printf("\nwarning: bogus SPC-line %d ", bquoteline);
- 438 bquote = bquoteline = 0;
- 439
- 442
- 442
- 442 truncation = 0;
- 443 }
- 444 ambiguous++;
- 445
- 446 continue;
- 447 }
- 448 if (*bp != ' ') count++;
- 449
- 453
- 453
- 453
- 453 continue;
- 454 }
- 455 else if ((*ibuf == ' ' || *ibuf == '`' ) && (len == 2 || len == 3))
- 456 {
- 457 bquote = 1;
- 458 if (bquoteline)
- 459 {
- 460 if (verbose) printf("\nwarning: bogus SPC-line %d ", bquoteline);
- 461 truncation = 0;
- 462 }
- 463 bquoteline = line;
- 464 if (ambiguous)
- 465 {
- 466 if (count > 0)
- 467 if (verbose) printf("\nwarning: garbage at end %d ", line);
- 468 if (ambiguous > 1)
- 469 if (verbose) printf("\nambiguous data at end %d ", line);
- 470 ExplodeLine(bp);
- 471 break;
- 472 }
- 473 }
- 474 else if ((end = !strncmp(ibuf, "end\n", 4)) && ! ambiguous && bquote)
- 475 {
- 476
- 477 break;
- 478 }
- 479 else if (*ibuf == 'M')
- 480 {
- 481 if (len != mlen)
- 482 {
- 483 if (verbose && uuchk(ibuf))
- 484 {
- 485 if (! truncation)
- 486 {
- 487 printf("\nwarning: truncated data line %d ", line);
- 488 fflush((&__iob[1]));
- 489 truncation = 1;
- 490 }
- 491 else
- 492 {
- 493 printf("%d ", line);
- 494 fflush((&__iob[1]));
- 495 }
- 496 }
- 497 }
- 498 else
- 499 {
- 500 mode = 1;
- 501 if (! secure)
- 502 ExplodeLine(ibuf);
- 503 else
- 504 {
- 505 mode = ExplodeLineCheck(ibuf);
- 506 ;
- 507 }
- 508 if (mode)
- 509 {
- 510
- 511 count = ambiguous = 0;
- 512 if (bquote)
- 513 {
- 514 if (verbose) printf("\nwarning: bogus SPC-line %d ", bquoteline);
- 515 bquoteline = bquote = 0;
- 516
- 520
- 520
- 520
- 520 truncation = 0;
- 521 }
- 522 }
- 523 }
- 524 }
- 525 }
- 526 fclose(ofp);
- 527
- 528 if (! ambiguous && ! end) if (verbose) printf("\nwarning: no end line ");
- 529 if (! bquote)
- 530 {if (verbose) printf("\nend of uucode not found\n");}
- 531 else
- 532 {if (verbose) printf("-- done\n");}
- 533 }
- 534 }
- +++ Warning: implicit return in non-void function
- 535
- 536
- 537
- 548
- 548
- 548
- 548
- 548
- 548
- 548
- 548
- 548
- 548
- 548
- 549
- 550 ExplodeLine(char *str)
- 551 {
- 552 i = (((*str) - ' ') & 077);
- 553 p = ++str;
- 554
- 555 while (i > 0)
- 556 {
- 557 if (i >= 3)
- 558 {
- 559 x = ((((*p) - ' ') & 077) << 2); p++;
- 560 x |= ((((*p) - ' ') & 077) >> 4);
- 561 y = ((((*p) - ' ') & 077) << 4); p++;
- 562 y |= ((((*p) - ' ') & 077) >> 2);
- 563 z = ((((*p) - ' ') & 077) << 6); p++;
- 564 z |= ((((*p) - ' ') & 077));
- 565 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (x)) : __flsbuf(x,ofp));
- 566 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (y)) : __flsbuf(y,ofp));
- 567 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (z)) : __flsbuf(z,ofp));
- 568 }
- 569 else if (i >= 2)
- 570 {
- 571 x = ((((*p) - ' ') & 077) << 2); p++;
- 572 x |= ((((*p) - ' ') & 077) >> 4);
- 573 y = ((((*p) - ' ') & 077) << 4); p++;
- 574 y |= ((((*p) - ' ') & 077) >> 2);
- 575 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (x)) : __flsbuf(x,ofp));
- 576 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (y)) : __flsbuf(y,ofp));
- 577 }
- 578 else if (i >= 1)
- 579 {
- 580 x = ((((*p) - ' ') & 077) << 2); p++;
- 581 x |= ((((*p) - ' ') & 077) >> 4);
- 582 (--((ofp)->__ocnt) >= 0 ? (*((ofp)->__ptr)++ = (x)) : __flsbuf(x,ofp));
- 583 }
- 584
- 585 str += 4;
- 586 p = str;
- 587 i -= 3;
- 588 }
- 589 }
- 590
- 591
- 592
- 596
- 596
- 596
- 596 unsigned char data[50];
- 597
- 598
- 603
- 603
- 603
- 603
- 603 int ExplodeLineCheck(char *str)
- 604 {
- 605 unsigned char *d;
- 606
- 607 i = (((*str) - ' ') & 077);
- 608 p = ++str;
- 609 d = data;
- 610 while (i > 0)
- 611 {
- 612 if (i >= 3)
- 613 {
- 614 x = ((((*p) - ' ') & 077) << 2); p++;
- 615 x |= ((((*p) - ' ') & 077) >> 4);
- 616 y = ((((*p) - ' ') & 077) << 4); p++;
- 617 y |= ((((*p) - ' ') & 077) >> 2);
- 618 z = ((((*p) - ' ') & 077) << 6); p++;
- 619 z |= ((((*p) - ' ') & 077));
- 620 *d++ = x; *d++ = y; *d++ = z;
- 621
- 622 if (*p >= 'a' || *(p-1) >= 'a' || *(p-2) >= 'a' || *(p-3) >= 'a')
- 623 return(0);
- 624 }
- 625 else if (i >= 2)
- 626 {
- 627 x = ((((*p) - ' ') & 077) << 2); p++;
- 628 x |= ((((*p) - ' ') & 077) >> 4);
- 629 y = ((((*p) - ' ') & 077) << 4); p++;
- 630 y |= ((((*p) - ' ') & 077) >> 2);
- 631 *d++ = x; *d++ = y;
- 632
- 633 if (*p >= 'a' || *(p-1) >= 'a' || *(p-2) >= 'a')
- 634 return(0);
- 635 }
- 636 else if (i >= 1)
- 637 {
- 638 x = ((((*p) - ' ') & 077) << 2); p++;
- 639 x |= ((((*p) - ' ') & 077) >> 4);
- 640 *d++ = x;
- 641 if (*p >= 'a' || *(p-1) >= 'a')
- 642 return(0);
- 643 }
- 644 str += 4;
- 645 p = str;
- 646 i -= 3;
- 647 }
- 648 *d = 0;
- 649 fwrite(data, 1, d-data, ofp);
- 650 return(1);
- 651 }
- 652
- 653
- +++ Warning: static 'obuf' declared but not used
-